///////////////////////////////////////////////////////////////////////////////
// Name:        detectobjects.h
// Purpose:     Detectobjects function
// Created:     2006
// Copyright:   (c) 2006, Ivan Laptev, TT Solutions
// License:     GPL, Please contact us for commercial license.
//              http://www.tt-solutions.com/
///////////////////////////////////////////////////////////////////////////////
#ifndef DETECTOBJECTS_H_
#define DETECTOBJECTS_H_

#include "objectdet/common.h"

#include "objectdet/adacascadeclass.h"

/**
 * Classify source image pixels according to cluster_means_norm matrix.
 *
 * Return a pair of matrices of the same size as source_image
 * 1st - .first  - timg
 * 2nd - .second - wimg
 */
boost::tuple<pMat, pMat> ClassifyImagePixels(pMat source_image,
                                             pMat cluster_means_norm,
                                             PixClass pixclass );

arrMat IntegralBlockHist(pMat timg,
                         pMat wimg,
                         size_t cluster_number,
                         size_t dx, size_t dy );

typedef std::vector<SubWindowInfo> SubWindows;

//*** x-y dimensions of the minimal block in block histograms
struct HistBlockSize
{
    double dx;
    double dy;
	HistBlockSize(double dxin, double dyin):dx(dxin),dy(dyin){}
};
typedef std::vector<HistBlockSize> HistBlockSizeArray;
typedef std::vector<double> ScaleFctArray;

IMPEXP
SubWindows DetectObjects(pImage src,
                         Model const & model, 
                         pMat cluster_means,
                         pMat cov_matrix,
                         pMat cluster_means_norm,
						 int pixclass,
						 HistBlockSizeArray bsarray,
						 ScaleFctArray scarray);

void ClearModelCache(Model const & model);

#endif

